<template>
  <div class="container" ref="mainCon">
    <div class="mainCon">
      <div class="spacing"></div>
      <div class="proDetailsListBox">
        <el-table
          :data="tableList"
          v-loading="loading"
          :max-height="tableHeight"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column
            prop="year"
            label="填报年份"
            min-width="120"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="dwlx"
            label="单位类型"
            min-width="160"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="zgZgzgrs"
            label="在岗职工人数"
            min-width="200"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="htGdhtrs"
            label="签订劳动合同人数"
            min-width="200"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="bcGzze"
            label="年度工资总额（万元）"
            min-width="200"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="shzt"
            label="审核状态"
            min-width="120"
            align="center"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            label="操作"
            align="center"
            fixed="right"
            min-width="100"
          >
            <template slot-scope="scope">
              <el-link type="primary" @click="toDetail(scope.row)"
                >查看详情</el-link
              >
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关数据"></emptyTable>
          </div>
        </el-table>
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
          @getpageNo="getpageNo"
          @getpageSize="getpageSize"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import common from '../../kits/common'
export default {
  name: 'writtenReview',
  props: {
    companyId: {
      type: String,
      default: '',
    },
    companyName: {
      type: String,
      default: '',
    },
    uscc: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      tableHeight: null,
      filterField: {
        uscc: this.uscc,
      },
      requestUrl: 'api-c/compexamine/expand/compexamine',
      pageSize: 20,
      pageNo: 1,
      tableList: [],
    }
  },
  mounted() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData(this.pageNo, this.pageSize)
    })
    this.$nextTick(function () {
      this.tableHeight = window.innerHeight - 324
      // 监听窗口大小变化
      let self = this
      window.onresize = function () {
        self.tableHeight = window.innerHeight - 324
      }
    })
  },
  methods: {
    getpageSize(val) {
      this.pageSize = val
    },
    getpageNo(val) {
      this.pageNo = val
    },
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    toDetail(row) {
      this.$router.push({
        path: '/home/enterpriseArchives/writtenReviewDetail',
        query: {
          row: JSON.stringify(row),
          companyId: this.companyId,
          companyName: this.companyName,
          uscc: this.uscc,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/enterpriseArchives/writtenReviewDetail',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style lang="less" scoped>
.proDetailsListBox {
  padding: 24px;
  background: #fff;
}
@import '../../../static/css/filterArea.less';
</style>
